package org.mf.domain;

import java.io.Serializable;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

/**
 */

@Entity
@NamedQueries({
		@NamedQuery(name = "findAllCustomers", query = "select myCustomer from Customer myCustomer"),
		@NamedQuery(name = "findCustomerByCreatedAt", query = "select myCustomer from Customer myCustomer where myCustomer.createdAt = ?1"),
		@NamedQuery(name = "findCustomerById", query = "select myCustomer from Customer myCustomer where myCustomer.id = ?1"),
		@NamedQuery(name = "findCustomerByName", query = "select myCustomer from Customer myCustomer where myCustomer.name = ?1"),
		@NamedQuery(name = "findCustomerByNameContaining", query = "select myCustomer from Customer myCustomer where myCustomer.name like ?1"),
		@NamedQuery(name = "findCustomerByPrimaryKey", query = "select myCustomer from Customer myCustomer where myCustomer.id = ?1"),
		@NamedQuery(name = "findCustomerByUpdatedAt", query = "select myCustomer from Customer myCustomer where myCustomer.updatedAt = ?1") })
@Table(catalog = "micro_finance", name = "customers")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(namespace = "MicroFinance/org/mf/domain", name = "Customer")
public class Customer extends DomainObject implements Serializable {
	private static final long serialVersionUID = 1L;

	/**
	 */

	@Column(name = "id", nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@Id
	@XmlElement
	Integer id;
	/**
	 */

	@Column(name = "name", length = 64, nullable = false)
	@Basic(fetch = FetchType.EAGER)
	@XmlElement
	String name;

	/**
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 */
	public Integer getId() {
		return this.id;
	}

	/**
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 */
	public String getName() {
		return this.name;
	}

	/**
	 */
	public Customer() {
	}

	/**
	 * Copies the contents of the specified bean into this bean.
	 *
	 */
	public void copy(Customer that) {
		setId(that.getId());
		setName(that.getName());
		setCreatedAt(that.getCreatedAt());
		setUpdatedAt(that.getUpdatedAt());
	}

	/**
	 * Returns a textual representation of a bean.
	 *
	 */
	public String toString() {

		StringBuilder buffer = new StringBuilder();

		buffer.append("id=[").append(id).append("] ");
		buffer.append("name=[").append(name).append("] ");
		buffer.append("createdAt=[").append(this.getCreatedAt()).append("] ");
		buffer.append("updatedAt=[").append(this.getUpdatedAt()).append("] ");

		return buffer.toString();
	}

	/**
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = (int) (prime * result + ((id == null) ? 0 : id.hashCode()));
		return result;
	}

	/**
	 */
	public boolean equals(Object obj) {
		if (obj == this)
			return true;
		if (!(obj instanceof Customer))
			return false;
		Customer equalCheck = (Customer) obj;
		if ((id == null && equalCheck.id != null) || (id != null && equalCheck.id == null))
			return false;
		if (id != null && !id.equals(equalCheck.id))
			return false;
		return true;
	}
}
